from securities import models

def initialize_securities(symbols=None):
  if symbols is None:
    from core.initialization.data.symbols import DEFAULT_SYMBOLS
    symbols = DEFAULT_SYMBOLS
  
  print 'Ready to fetch %d symbols' % len(symbols)
  i = 0
  for symbol in symbols:
    try:
      models.Security.getFromSymbol(symbol)
    except Exception, e:
      print 'Failed to fetch %s: %s' % (symbol, e)
    i += 1
    if i % 25 == 0:
      print 'Fetched %d/%d' % (i, len(symbols))
